#include<stdio.h>
#include<unistd.h>
#include<string.h>

int main(){
    int fd[2];
   int ret = pipe(fd);
   if(ret<0){
       perror("pipe");
       return 0;
   }
    int f=fork();
    if(f<0){
        perror("fork");
        return 0;
    }else if(f==0){
        char buf[1024]={0};
        read(fd[0],buf,sizeof(buf)-1);
        printf("i am child , then i have read :%s\n",buf);
    }else{
        
        const char*lp="i am father";
        write(fd[1],lp,strlen(lp));
    }

    return 0;
}
